﻿using System.Collections.Generic;

namespace Loki.Model
{
    /// <summary>
    /// Interface for entity key mappers.
    /// </summary>
    /// <typeparam name="TEntityClass"></typeparam>
    public interface IKeyMapper<TEntityClass>
    {
        /// <summary>
        /// Gets the entities corresponding to the specified value.
        /// </summary>
        /// <param name="P_Key">The key.</param>
        /// <returns></returns>
        IEnumerable<TEntityClass> GetAllByKey(object P_Key);

        /// <summary>
        /// Resets the mapper.
        /// </summary>
        void Reset();

        /// <summary>
        /// Registers an entity into mapper.
        /// </summary>
        /// <param name="P_Entity">The entity.</param>
        bool Register(TEntityClass P_Entity);

        /// <summary>
        /// Unregisters an entity into mapper.
        /// </summary>
        /// <param name="P_Entity">The entity.</param>
        void Remove(TEntityClass P_Entity);

        /// <summary>
        /// Determines whether the specified key is loaded in mapper.
        /// </summary>
        /// <param name="P_Key">The key.</param>
        /// <returns>
        ///     Returns <c>true</c> if the specified key is loaded; otherwise, <c>false</c>.
        /// </returns>
        bool IsLoaded(object P_Key);

        /// <summary>
        /// Computes the index value.
        /// </summary>
        /// <param name="P_Entity">The entity.</param>
        /// <returns></returns>
        object ComputeIndex(TEntityClass P_Entity);

        /// <summary>
        /// Marks the specified key as loaded in mapper.
        /// </summary>
        /// <param name="P_Key">The Key.</param>
        void MarkAsLoaded(object P_Key);
    }
}
